package org.indexador.hadoop;

import java.io.*;
import java.util.*;

import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;

public class ArtigoWikipediaMapper extends
    Mapper<LongWritable, Text, Text, IntWritable> {
  private final IntWritable id = new IntWritable(1);
  private Text titulo = new Text();

  public void map(LongWritable key, Text value, Context context)
      throws InterruptedException {
    String linha = value.toString();
    StringTokenizer token = new StringTokenizer(linha);
    try {
      //      id.set(Integer.valueOf(token.nextToken()));
      if (token.hasMoreTokens()) {
        id.set(Integer.valueOf(1));
        titulo.set(token.nextToken());
        context.write(titulo, id);
      }
    } catch (Exception e) {
      System.out.println("Erro: " + e);
    }
  }
}